package com.atguigu.gmall.search.entity;

import lombok.Data;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;
@Document(indexName = "goods",shards = 3,replicas = 2)
@Data
public class Goods {
    //商品列表字段
    @Id
    private Long skuId;
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String title;//标题
    @Field(type = FieldType.Keyword,index = false)
    private String subtitle;//副标题
    @Field(type = FieldType.Keyword,index = false)
    private String defaultImage;
    @Field(type = FieldType.Double)
    private double price;

    //排序及过滤
    @Field(type = FieldType.Long)
    private long sales =0l;
    @Field(type = FieldType.Date,format = DateFormat.date)
    private Date createTime;
    @Field(type = FieldType.Boolean)
    private boolean store =false;

    //品牌聚合字段
    @Field(type = FieldType.Long)
    private long brandId;
    @Field(type = FieldType.Keyword)
    private String brandName;
    @Field(type = FieldType.Keyword,index = false)
    private String logo;

    //分类聚合字段
    @Field(type = FieldType.Long)
    private long categoryId;
    @Field(type = FieldType.Keyword)
    private String categoryName;

    //销售属性相关字段
    @Field(type = FieldType.Nested)
    private List<SearchAttrValue> searchAttrs;









}
